Skip to content

crypto: ignore directory paths in OPENSSL_CONF#63273

Open
haramj wants to merge 1 commit into
nodejs:mainfrom
haramj:haramj-patch-260512-1
Open

crypto: ignore directory paths in OPENSSL_CONF#63273
haramj wants to merge 1 commit into
nodejs:mainfrom
haramj:haramj-patch-260512-1

Conversation

@haramj
Copy link
Copy Markdown
Member

@haramj haramj commented May 13, 2026

Summary

This PR improves the robustness of Node.js startup when the OPENSSL_CONF environment variable points to a directory instead of a file. Currently, such cases cause a fatal OpenSSL configuration error, preventing Node.js from starting. This change detects directory paths early, emits a descriptive warning, and allows Node.js to continue booting using default settings.

Root Cause Analysis

In src/node.cc, the InitializeOncePerProcessInternal function attempts to load the OpenSSL configuration. If OPENSSL_CONF is set to a directory (e.g., /tmp or C:), OpenSSL's internal fopen() fails, raising a fatal error that triggers an early return and process exit.

Changes

• Pre-check with stat(): Detects if conf_file is a directory before passing it to OpenSSL.
• Cross-platform Compatibility: Implemented directory detection using S_ISDIR and bitwise masks for environments where the macro is unavailable.
• Warning Instead of Exit: Replaced the fatal error exit with a fprintf(stderr, ...) warning to inform the user that the directory path is being ignored.
• Error Queue Management: Ensured the OpenSSL error queue is cleared using ERR_clear_error() to prevent side effects for subsequent operations.

Validation & Testing

  1. Manual Verification (macOS Apple Silicon)
    I performed a clean build after running make distclean and verified the fix:
    $ export OPENSSL_CONF=/tmp
    $ ./node --use-system-ca -e "console.log('Final Validation: I am alive!')"

Actual Output:

Warning: OPENSSL_CONF path is a directory; ignoring: /tmp
Final Validation: I am alive!

  1. Automated Test Suite
    I ran the full test suite using python3 tools/test.py:
    • Passed: 5284 tests.
    • Failed: 7 tests (All verified as missing FFI test fixtures, unrelated to this change).
    • All parallel/test-crypto-* tests passed successfully.
  2. Linting
    • Passed make lint-cpp (Ensured all lines are 80 characters or less).

Fixes: #63256

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/startup

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels May 13, 2026
@haramj haramj force-pushed the haramj-patch-260512-1 branch from 0ac0c7d to 09c23bb Compare May 13, 2026 05:52
@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

❌ Patch coverage is 30.76923% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.06%. Comparing base (78bbee3) to head (8979aad).
⚠️ Report is 18 commits behind head on main.

Files with missing lines Patch % Lines
src/node.cc 30.76% 8 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63273      +/-   ##
==========================================
+ Coverage   90.04%   90.06%   +0.01%     
==========================================
  Files         713      714       +1     
  Lines      225003   225255     +252     
  Branches    42536    42581      +45     
==========================================
+ Hits       202606   202866     +260     
+ Misses      14177    14170       -7     
+ Partials     8220     8219       -1     
Files with missing lines Coverage Δ
src/node.cc 75.89% <30.76%> (-0.27%) ⬇️

... and 40 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

PR-URL: nodejs#63218
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Signed-off-by: haramjeong <04harams77@gmail.com>
@haramj haramj force-pushed the haramj-patch-260512-1 branch from 09c23bb to 8979aad Compare May 14, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--use-system-ca fails to start with bad OPENSSL_CONF set

2 participants